/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgModuloPrincipal.pkgConfiguracionRegional;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import pkgUtil.Message;
import pkgUtil.UtilLayoutPantalla;
import pkgUtil.pkgFrameworkXML.pkgSupport.XmlWriterException;

/**
 *
 * @author Administrador
 */
public class PllaConfiguracionRegional extends javax.swing.JDialog {

    private GestorConfigRegional gestorConfigReg;

    /**
     * Creates new form PllaConfiguracionRegional
     */
    public PllaConfiguracionRegional() {
        initComponents();
    }

    public PllaConfiguracionRegional(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnGLocale = new javax.swing.ButtonGroup();
        jPanelPaisIdioma = new javax.swing.JPanel();
        rBtnArgEs = new javax.swing.JRadioButton();
        rBtnUSEn = new javax.swing.JRadioButton();
        jPanelSepDecimales = new javax.swing.JPanel();
        lblSimboloDecimal = new javax.swing.JLabel();
        cmbSepDecimal = new javax.swing.JComboBox();
        lblSimboloSepMiles = new javax.swing.JLabel();
        cmbSepMiles = new javax.swing.JComboBox();
        lblDesSimboloDecimal = new javax.swing.JLabel();
        lblDesSimboloMiles = new javax.swing.JLabel();
        btnAceptar = new javax.swing.JButton();
        btnCerrar = new javax.swing.JButton();
        cbConfigDefault = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        lblTituloPais = new javax.swing.JLabel();
        lblValuePais = new javax.swing.JLabel();
        lblTituloIdioma = new javax.swing.JLabel();
        lblValueIdioma = new javax.swing.JLabel();
        lblTituloSepDecimal = new javax.swing.JLabel();
        lblValueSepDecimal = new javax.swing.JLabel();
        lblTituloSepMil = new javax.swing.JLabel();
        lblValueSepMil = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Configuracion Regional");
        setResizable(false);

        jPanelPaisIdioma.setBorder(javax.swing.BorderFactory.createTitledBorder("País - Idioma"));

        btnGLocale.add(rBtnArgEs);
        rBtnArgEs.setText("Argentina - Español");

        btnGLocale.add(rBtnUSEn);
        rBtnUSEn.setText("United States - Inglés");

        javax.swing.GroupLayout jPanelPaisIdiomaLayout = new javax.swing.GroupLayout(jPanelPaisIdioma);
        jPanelPaisIdioma.setLayout(jPanelPaisIdiomaLayout);
        jPanelPaisIdiomaLayout.setHorizontalGroup(
            jPanelPaisIdiomaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPaisIdiomaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelPaisIdiomaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(rBtnArgEs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(rBtnUSEn, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelPaisIdiomaLayout.setVerticalGroup(
            jPanelPaisIdiomaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelPaisIdiomaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rBtnArgEs)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rBtnUSEn)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelSepDecimales.setBorder(javax.swing.BorderFactory.createTitledBorder("Símbolos Numéricos"));

        lblSimboloDecimal.setText("Símbolo decimal:");

        cmbSepDecimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbSepDecimalActionPerformed(evt);
            }
        });

        lblSimboloSepMiles.setText("Símbolo separación de miles");

        cmbSepMiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbSepMilesActionPerformed(evt);
            }
        });

        lblDesSimboloDecimal.setText("DESCRIPCION");

        lblDesSimboloMiles.setText("DESCRIPCION");

        javax.swing.GroupLayout jPanelSepDecimalesLayout = new javax.swing.GroupLayout(jPanelSepDecimales);
        jPanelSepDecimales.setLayout(jPanelSepDecimalesLayout);
        jPanelSepDecimalesLayout.setHorizontalGroup(
            jPanelSepDecimalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelSepDecimalesLayout.createSequentialGroup()
                .addComponent(lblSimboloSepMiles)
                .addContainerGap())
            .addGroup(jPanelSepDecimalesLayout.createSequentialGroup()
                .addGroup(jPanelSepDecimalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cmbSepDecimal, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblSimboloDecimal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cmbSepMiles, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelSepDecimalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblDesSimboloDecimal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanelSepDecimalesLayout.createSequentialGroup()
                        .addComponent(lblDesSimboloMiles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanelSepDecimalesLayout.setVerticalGroup(
            jPanelSepDecimalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelSepDecimalesLayout.createSequentialGroup()
                .addComponent(lblSimboloDecimal)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelSepDecimalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cmbSepDecimal)
                    .addComponent(lblDesSimboloDecimal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(lblSimboloSepMiles)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelSepDecimalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cmbSepMiles)
                    .addComponent(lblDesSimboloMiles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        btnAceptar.setText("Aceptar");
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        btnCerrar.setText("Cerrar");
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });

        cbConfigDefault.setText("Configuración Predeterminada");
        cbConfigDefault.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbConfigDefaultActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Configuración actual"));

        lblTituloPais.setText("País:");

        lblValuePais.setText("<<PAIS>>");

        lblTituloIdioma.setText("Idioma:");

        lblValueIdioma.setText("<<IDIOMA>>");

        lblTituloSepDecimal.setText("Símbolo Separador Decimal:");

        lblValueSepDecimal.setText("<<SEP_DECIMAL>>");

        lblTituloSepMil.setText("Símbolo Separador Miles:");

        lblValueSepMil.setText("<<SEP_MILES>>");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblTituloPais)
                        .addGap(31, 31, 31)
                        .addComponent(lblValuePais))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblTituloIdioma)
                        .addGap(18, 18, 18)
                        .addComponent(lblValueIdioma))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTituloSepDecimal)
                            .addComponent(lblTituloSepMil))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblValueSepDecimal)
                            .addComponent(lblValueSepMil, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTituloPais)
                    .addComponent(lblValuePais))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTituloIdioma)
                    .addComponent(lblValueIdioma))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTituloSepDecimal)
                    .addComponent(lblValueSepDecimal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTituloSepMil)
                    .addComponent(lblValueSepMil))
                .addGap(0, 11, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelPaisIdioma, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelSepDecimales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnCerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(cbConfigDefault)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelPaisIdioma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelSepDecimales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cbConfigDefault)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCerrar)
                    .addComponent(btnAceptar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbConfigDefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbConfigDefaultActionPerformed
        opcionConfiguracionPredeterminada();
    }//GEN-LAST:event_cbConfigDefaultActionPerformed

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        cerrarPantalla();
    }//GEN-LAST:event_btnCerrarActionPerformed

    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
        opcionAceptarPorBD();
    }//GEN-LAST:event_btnAceptarActionPerformed

    private void cmbSepDecimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbSepDecimalActionPerformed
        setDescripcionSeparadorDecimal();
    }//GEN-LAST:event_cmbSepDecimalActionPerformed

    private void cmbSepMilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbSepMilesActionPerformed
        setDescripcionSeparadorMiles();
    }//GEN-LAST:event_cmbSepMilesActionPerformed

    private void setDescripcionSeparadorDecimal() {
        try {
            Separator sep = (Separator) cmbSepDecimal.getSelectedItem();
            if (sep.getDescription() == null || sep.getDescription().isEmpty()) {
                lblDesSimboloDecimal.setText(Constants.SEP_DESCRIPTION_DEFAULT);
                return;
            }
            lblDesSimboloDecimal.setText(sep.getDescription());
        } catch (Exception ex) {
            lblDesSimboloDecimal.setText(Constants.SEP_DESCRIPTION_DEFAULT);
        }
    }

    private void setDescripcionSeparadorMiles() {
        try {
            Separator sep = (Separator) cmbSepMiles.getSelectedItem();
            if (sep.getDescription() == null || sep.getDescription().isEmpty()) {
                lblDesSimboloMiles.setText(Constants.SEP_DESCRIPTION_DEFAULT);
                return;
            }
            lblDesSimboloMiles.setText(sep.getDescription());
        } catch (Exception ex) {
            lblDesSimboloMiles.setText(Constants.SEP_DESCRIPTION_DEFAULT);
        }
    }

    private void opcionAceptar() {
        UtilLayoutPantalla.initWaiting(this);
        try {
            ContextEntity ctxEntity = new ContextEntity();
            setLocaleLanguage(ctxEntity);
            ctxEntity.setSepDecimales(getSepDecimal());
            ctxEntity.setSepMiles(getSepMiles());
            gestorConfigReg.crearXmlConfiguracionRegional(ctxEntity);
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("El archivo de configuración regional se ha creado exitosamente.\nPor favor reinicie el sistema para que tome la nueva configuración.\nNombre archivo: " + Constants.NAME_XML_CONTEXT, "Mensaje", Message.TIPO_INFORMACION);
            cerrarPantalla();
        } catch (XmlWriterException ex) {
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("Error en creación de archivo XML para configuración regional:\n\n" + ex.getMessage(), "Error", Message.TIPO_ERROR);
        } catch (FileNotFoundException ex) {
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("Error en creación de archivo para configuración regional:\n\n" + ex.getMessage(), "Error", Message.TIPO_ERROR);
        } catch (IOException ex) {
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("Error en creación de archivo para configuración regional:\n\n" + ex.getMessage(), "Error", Message.TIPO_ERROR);
        } catch (Exception ex) {
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("Error en creación de archivo para configuración regional:\n\n" + ex.getMessage(), "Error", Message.TIPO_ERROR);
        }
    }

    private void opcionAceptarPorBD() {
        UtilLayoutPantalla.initWaiting(this);
        try {
            ContextEntity ctxEntity = new ContextEntity();
            setLocaleLanguage(ctxEntity);
            ctxEntity.setSepDecimales(getSepDecimal());
            ctxEntity.setSepMiles(getSepMiles());
            boolean res=gestorConfigReg.actualizarConfiguracionContextoJavaDB(ctxEntity);
            if(!res){
             throw new Exception("No se llevo a cabo la actualización. Reintente nuevamente.");
            }
            UtilLayoutPantalla.endWaiting(this);
            mostrarConfiguracionActual(ctxEntity);
            Message.mensaje_Estandar("La actualización de configuración de contexto se realizó exitosamente.\nPor favor reinicie el sistema para que tome la nueva configuración.", "Mensaje", Message.TIPO_INFORMACION);
            cerrarPantalla();
        } catch (SQLException ex) {
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("Error en actualización de configuración de contexto:\n\n" + ex.getMessage(), "Error", Message.TIPO_ERROR);
        } catch (Exception ex) {
            UtilLayoutPantalla.endWaiting(this);
            Message.mensaje_Estandar("Error en actualización de configuración de contexto:\n\n" + ex.getMessage(), "Error", Message.TIPO_ERROR);
        }
    }

    private char getSepDecimal() {
        Separator sep = (Separator) cmbSepDecimal.getSelectedItem();
        return sep.getCharSymbol();
    }

    private char getSepMiles() {
        Separator sep = (Separator) cmbSepMiles.getSelectedItem();
        return sep.getCharSymbol();
    }

    private void setLocaleLanguage(ContextEntity ctxEntity) {
        if (rBtnArgEs.isSelected()) {
            ctxEntity.setCountry(Constants.ENUM_LOCALE.COUNTRY_ARGENTINA.toString());
            ctxEntity.setLanguage(Constants.ENUM_LOCALE.LANGUAGE_ESPANIOL.toString());
            return;
        }

        ctxEntity.setCountry(Constants.ENUM_LOCALE.COUNTRY_US.toString());
        ctxEntity.setLanguage(Constants.ENUM_LOCALE.LANGUAGE_INGLES.toString());

    }

    private void opcionConfiguracionPredeterminada() {
        if (cbConfigDefault.isSelected()) {
            rBtnArgEs.setSelected(true);
            cmbSepDecimal.setSelectedItem(Constants.SEP_OBJ_DECIMAL_DEFAULT);
            cmbSepMiles.setSelectedItem(Constants.SEP_OBJ_MILES_DEFAULT);

            rBtnArgEs.setEnabled(false);
            rBtnUSEn.setEnabled(false);
            cmbSepDecimal.setEnabled(false);
            cmbSepMiles.setEnabled(false);
        } else {
            rBtnArgEs.setEnabled(true);
            rBtnUSEn.setEnabled(true);
            cmbSepDecimal.setEnabled(true);
            cmbSepMiles.setEnabled(true);
        }

    }

    /**
     * @param args the command line arguments
     */
    public void abrirPantalla() {
        try {
            cargarSimbolosDecimales();
            rBtnArgEs.setSelected(true);
            gestorConfigReg = new GestorConfigRegional();
            gestorConfigReg.setPllaConfigRegional(this);
            cargarConfiguracionActualBD();
            UtilLayoutPantalla.centrarEnPantallaJDialog(this);
            this.setModal(true);
            setVisible(true);
        } catch (Exception ex) {
            Message.mensaje_Estandar("Ocurrió un error al abrir la pantalla: " + ex.getMessage(), "Error", Message.TIPO_ERROR);
            cerrarPantalla();
        }
    }

    private void cargarSimbolosDecimales() {
        for (int i = 0; i < Constants.SEPARATOR_NUMERIC_SYMBOLS.length; i++) {
            cmbSepDecimal.addItem(Constants.SEPARATOR_NUMERIC_SYMBOLS[i]);
            cmbSepMiles.addItem(Constants.SEPARATOR_NUMERIC_SYMBOLS[i]);
        }
        cmbSepDecimal.setSelectedItem(Constants.SEP_OBJ_DECIMAL_DEFAULT);
        cmbSepMiles.setSelectedItem(Constants.SEP_OBJ_MILES_DEFAULT);

    }

    private void cargarConfiguracionActualBD() throws SQLException {
        ContextEntity ctxEntity = gestorConfigReg.getConfigContextAppByJavaDB();
        mostrarConfiguracionActual(ctxEntity);
    }

    private void mostrarConfiguracionActual(ContextEntity ctxEntity) {
        if (ctxEntity == null) {
            lblValuePais.setText(Constants.VALUE_INDEFINITE);
            lblValueIdioma.setText(Constants.VALUE_INDEFINITE);
            lblValueSepDecimal.setText(Constants.VALUE_INDEFINITE);
            lblValueSepMil.setText(Constants.VALUE_INDEFINITE);
        } else {
            lblValuePais.setText(ctxEntity.getCountry());
            lblValueIdioma.setText(ctxEntity.getLanguage());
            String sepDec = gestorConfigReg.getDescripcionParaSimbolo(String.valueOf(ctxEntity.getSepDecimales()));
            String sepMil = gestorConfigReg.getDescripcionParaSimbolo(String.valueOf(ctxEntity.getSepMiles()));
            lblValueSepDecimal.setText(sepDec != null ? sepDec + "("+String.valueOf(ctxEntity.getSepDecimales())+")": Constants.VALUE_INDEFINITE);
            lblValueSepMil.setText(sepMil != null ? sepMil + "("+String.valueOf(ctxEntity.getSepMiles())+")" : Constants.VALUE_INDEFINITE);
        }

    }

    private void cerrarPantalla() {
        this.dispose();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnCerrar;
    private javax.swing.ButtonGroup btnGLocale;
    private javax.swing.JCheckBox cbConfigDefault;
    private javax.swing.JComboBox cmbSepDecimal;
    private javax.swing.JComboBox cmbSepMiles;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelPaisIdioma;
    private javax.swing.JPanel jPanelSepDecimales;
    private javax.swing.JLabel lblDesSimboloDecimal;
    private javax.swing.JLabel lblDesSimboloMiles;
    private javax.swing.JLabel lblSimboloDecimal;
    private javax.swing.JLabel lblSimboloSepMiles;
    private javax.swing.JLabel lblTituloIdioma;
    private javax.swing.JLabel lblTituloPais;
    private javax.swing.JLabel lblTituloSepDecimal;
    private javax.swing.JLabel lblTituloSepMil;
    private javax.swing.JLabel lblValueIdioma;
    private javax.swing.JLabel lblValuePais;
    private javax.swing.JLabel lblValueSepDecimal;
    private javax.swing.JLabel lblValueSepMil;
    private javax.swing.JRadioButton rBtnArgEs;
    private javax.swing.JRadioButton rBtnUSEn;
    // End of variables declaration//GEN-END:variables
}
